package com.yitao.fdfs.service;

import com.yitao.fdfs.utils.FastDFSClient;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

@Service
public class FdfsFileService {

    /**
     * 文件上传
     *
     * @param file
     * @return
     * @throws Exception
     */
    public String uploadFile(MultipartFile file) throws Exception {
        FastDFSClient fastDFSClient = new FastDFSClient();
        return FastDFSClient.uploadFile(file.getBytes(), file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1, file.getOriginalFilename().length()));
    }
}
